﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameProject
{
    /// <summary>
    /// Denna klass gör det möjligt att skapa en karta
    /// av tiles, dessa tiles finns tillgängliga i content mappen.
    /// </summary>
    class Map // Klass som gör en karta av tiles 
    {
        private List<CollisionTiles> collisionTiles = new List<CollisionTiles>();



        public List<CollisionTiles> CollisionTiles
        {
            get { return collisionTiles; }
        }

        private int width;
        private int height = 500;
        public int Width
        {
            get { return width; }
        }

        public int Height
        {
            get { return height; }
        }

        public Map() { }

        /// <summary>
        /// Skapar kartan efter given indata.
        /// </summary>
        /// <param name="map"></param>
        /// <param name="size"></param>
        public void Generate(int[,] map,int size)
        {
            for (int x = 0; x < map.GetLength(1); x++)
            {
                for (int y = 0; y < map.GetLength(0); y++)
                {
                    int number = map[y, x];

                    if(number > 0 )
                    {
                        collisionTiles.Add(new CollisionTiles(number, new Rectangle(x * size, y * size, size,size)));
                        width += (x + 1) * size;
                    }
                }
            }
        }

        /// <summary>
        /// Målar ut alla tiles som genererats i
        /// medlemsfunktionen Generate
        /// </summary>
        /// <param name="spriteBatch"></param>

        public void Draw(SpriteBatch spriteBatch) 
        {
            foreach(CollisionTiles tile in collisionTiles)
            {
                tile.Draw(spriteBatch);
            }
        }

        internal CollisionTiles CollisionTiles1
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        internal Tiles Tiles
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }
    }
}
